package physics;

import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import org.jbox2d.common.Vec2;

import physics.Box2dUtil;

public class MyMouseListener implements MouseListener{
	GView gView;
    public MyMouseListener(GView gView){
    	this.gView= gView;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        if(MouseEvent.BUTTON1 == e.getButton()){
            addBallToWorld(e);
        }
    }

    private void addBallToWorld(MouseEvent e){
        int mx = e.getX()+50;
        int my = e.getY()+50;
        MyCircleBody bd=Box2dUtil.createBird(mx, my, 30, gView.myFrame.world, Color.RED);
        bd.body.applyLinearImpulse(new Vec2(300000, -150000), bd.body.getWorldCenter());
        gView.myFrame.bodyList.add(bd);
    }

    @Override
    public void mousePressed(MouseEvent e) {

    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }

    @Override
    public void mouseEntered(MouseEvent e) {

    }

    @Override
    public void mouseExited(MouseEvent e) {

    }
}
